= content_for :title do
  %h3.project-title
    Runner ##{@runner.id}
    .pull-right
      - if @runner.shared?
        %span.runner-state.runner-state-shared
          Shared
      - else
        %span.runner-state.runner-state-specific
          Specific



- if @runner.shared?
  .bs-callout.bs-callout-success
    %h4 This runner will process build from ALL UNASSIGNED projects
    %p
      If you want runners to build only specific projects, enable them in the table below.
      Keep in mind that this is a one way transition.
- else
  .bs-callout.bs-callout-info
    %h4 This runner will process build only from ASSIGNED projects
    %p You can't make this a shared runner.
%hr
= form_for @runner, url: admin_runner_path(@runner), html: { class: 'form-horizontal' } do |f|
  .form-group
    = label_tag :token, class: 'control-label' do
      Token
    .col-sm-10
      = f.text_field :token, class: 'form-control', readonly: true
  .form-group
    = label_tag :description, class: 'control-label' do
      Description
    .col-sm-10
      = f.text_field :description, class: 'form-control'
  .form-group
    = label_tag :tag_list, class: 'control-label' do
      Tags
    .col-sm-10
      = f.text_field :tag_list, class: 'form-control'
      .help-block You can setup builds to only use runners with specific tags
  .form-actions
    = f.submit 'Save', class: 'btn btn-save'

.row
  .col-md-6
    %h4 Restrict projects for this runner
    - if @runner.projects.any?
      %table.table
        %thead
          %tr
            %th Assigned projects
            %th
        - @runner.runner_projects.each do |runner_project|
          - project = runner_project.project
          %tr.alert-info
            %td
              %strong
                = project.name
            %td
              .pull-right
                = link_to 'Disable', [:admin, project, runner_project], method: :delete, class: 'btn btn-danger btn-xs'

    %table.table
      %thead
        %tr
          %th Project
          %th
            .pull-right
              = link_to 'Assign to all', assign_all_admin_runner_path(@runner),
                class: 'btn btn-sm assign-all-runner',
                title: 'Assign runner to all projects',
                method: :put

      %tr
        %td
          = form_tag admin_runner_path(@runner), class: 'form-inline', method: :get do
            .form-group
              = search_field_tag :search, params[:search], class: 'form-control'
            = submit_tag 'Search', class: 'btn'

        %td
      - @projects.each do |project|
        %tr
          %td
            = project.name
          %td
            .pull-right
              = form_for [:admin, project, project.runner_projects.new] do |f|
                = f.hidden_field :runner_id, value: @runner.id
                = f.submit 'Enable', class: 'btn btn-xs'
    = paginate @projects

  .col-md-6
    %h4 Recent builds served by this runner
    %table.builds.runner-builds
      %thead
        %tr
          %th Status
          %th Project
          %th Commit
          %th Finished at

      - @builds.each do |build|
        %tr.build.alert{class: build_status_alert_class(build)}
          %td.status
            = build.status

          %td.status
            = build.project.name

          %td.build-link
            = link_to project_build_path(build.project, build) do
              %strong #{build.short_sha}

          %td.timestamp
            - if build.finished_at
              %span #{time_ago_in_words build.finished_at} ago
